
package com.joysuch.wwyt.datadump.biz.query;

import cn.zlg.common.datadump.condition.QueryCondtionDef;
import cn.zlg.common.datadump.condition.QueryFieldCondition;
import cn.zlg.common.datadump.condition.QueryFieldConditionSet;
import cn.zlg.common.datadump.condition.SortFieldDef;
import com.joysuch.wwyt.bp.entity.dsl.QBpIndustrialPipeline;
import com.joysuch.wwyt.bp.entity.dsl.QBpProductionFacility;
import com.joysuch.wwyt.mh.entity.dsl.QMhMajorHazard;
import com.querydsl.core.types.Order;

import java.util.Arrays;
import java.util.List;

public class BpProductFacilityDumpQueryBean implements QueryCondtionDef {

    @Override
    public List<QueryFieldConditionSet> getConditionSet() {
        return Arrays.asList(
                QueryFieldConditionSet.Builder().names("name", "nameOrCode").or(
                        new QueryFieldCondition("nameOrCode", QBpProductionFacility.bpProductionFacility,
                                QBpProductionFacility.bpProductionFacility.name, QBpProductionFacility.bpProductionFacility.id,
                                "contains"),
                        new QueryFieldCondition("nameOrCode", QBpProductionFacility.bpProductionFacility,
                                QBpProductionFacility.bpProductionFacility.code, QBpProductionFacility.bpProductionFacility.id,
                                "contains")
                ).build()
        );
    }

    @Override
    public QueryFieldCondition[] getAllConditionDef() {
        QBpProductionFacility q = QBpProductionFacility.bpProductionFacility;
        return new QueryFieldCondition[] { new QueryFieldCondition("ids", q,
                q.id, q.id, "in"),

                new QueryFieldCondition("repairState", q, q.repairState, q.id, "eq"),
                // 停用状态
                new QueryFieldCondition("state", q, q.state, q.id, "eq"),
                new QueryFieldCondition("safeStatus", q,  q.safeStatus, q.id, "eq"),

                new QueryFieldCondition("majorHazardId", QMhMajorHazard.mhMajorHazard,
                        QMhMajorHazard.mhMajorHazard.id,  QMhMajorHazard.mhMajorHazard.id, q.majorHazardId, "eq"),

        };
    }

    @Override
    public SortFieldDef[] getAllSortFieldDef() {
        return new SortFieldDef[] {
                new SortFieldDef(QBpProductionFacility.bpProductionFacility.id, "id", Order.DESC, true),
                new SortFieldDef(QBpProductionFacility.bpProductionFacility.name, "name", Order.ASC) };
    }
}
